package pso;

public class Rosenbrock extends BlackBoxFunction{
	public Rosenbrock(int dimension) {
		super(new Point(dimension, -30.0), new Point(dimension, 30.0));
	}
	
	protected double evaluateHelper(Point p)
	{
		double sum = 0;
		for(int i = 0; i < p.getDimension()-1; i++)
		{
			
			sum += 100 * Math.pow((p.getCoordinates()[i+1] - p.getCoordinates()[i] * p.getCoordinates()[i] ),2) 
					+ Math.pow(Math.pow(1-p.getCoordinates()[0], 2),2);
		}
		return sum;
	}
}
